//sdk相关
var http = require("http")
var model = function() {}

var ctys = ["VN","TW","HK","MO","IN","KR","JP","PH","SG","VN","VN","VN","VN","VN","HK","TW"]
//申请IP
model.applyIp = function(num,time,cb) {
	var cty = ctys[Math.floor(Math.random() * ctys.length)]
	var url = "http://api.ipipgo.com/ip?cty="+cty+"&c="+num+"&pt=2&ft=json&rep=1&key=718dc7a0&ts="+time
	http.get(url,function(res) {
		var _data = ""
	  	res.on("data",function(data) {
	  		_data += data
	  	})
	  	res.on("end",function() {
	  		_data = JSON.parse(_data)
	  		if(cb)
	  			cb(_data)
	  	})
		res.on("error", err => {
			if(cb)
				cb(false)
		});
	})
}

module.exports = model